﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraBars;
using DevExpress.XtraGrid.Views.Grid;
using System.Diagnostics;
using DTO;
using BUS;
using System.Data.SqlClient;
namespace GPBenhLanh
{
    public partial class frmDaTiepNhan : DevExpress.XtraBars.Ribbon.RibbonForm
    {
        public frmDaTiepNhan()
        {
            InitializeComponent();
            initControl(this);          
        }
        public frmDaTiepNhan(int sel)
        {
            InitializeComponent();
            initControl(this);
            select = sel;
        }

        private int select;
        private static string strConnectTN = "";        
        private static string strPathHinh = "";
        private bool firtLoad = true;//flag danh dau lau dau tien load len
        private int[] dataRes = new int[3];
        int maxSoXanh;
        SqlConnection conpk;

        public static string _strConnectPK;
        //string SoXanh;
        /// <summary>
        /// get thong tin ket noi den database phKham
        /// </summary>
        public void getConnectStringPK()
        {
            string _sConnection = Uit.it_Conn.getConnectString("ConnectPhkham");
            _strConnectPK = axEnCrypt1.DeCrypt(_sConnection, Uit.it_Conn.getPasswordString());
        }
        
        public void CnPKham()
        {
            if (conpk == null || conpk.State == ConnectionState.Closed)
            {
                getConnectStringPK();
                conpk = new SqlConnection();
                conpk = Uit.it_Conn.getConnect(_strConnectPK);
            }
        }
        public void getPathStrHinh()
        {
            string _sConnection = Uit.it_Conn.getConnectString("pathStrHinh");
            strPathHinh = axEnCrypt1.DeCrypt(_sConnection, Uit.it_Conn.getPasswordString());
        }

        private void initControl(Control ctrl)
        {
            // Bỏ qua điều kiểm trừ khi nó là TextBox.
            if (ctrl.Tag == "text")
            {
                ctrl.Text = "";
            }

            // Xử lý các điều kiểm một cách đệ quy.
            // Điều này cần thiết khi có một điều kiểm chứa nhiều 
            // điều kiểm khác (ví dụ, khi bạn sử dụng Panel, 
            // GroupBox, hoặc điều kiểm container nào khác).
            foreach (Control ctrlChild in ctrl.Controls)
            {
                initControl(ctrlChild);
            }
        }

        /// <summary>
        /// Get danh sach benh nhan theo loai benh nhan 
        /// va tinh trang da xac nhan hay chua
        /// </summary>
        /// <param name="nLoaiBN">1: ngoai tru; 2: noi tru; 3: mien giam; 
        /// 4: chuong trinh; 5: ksk</param>
        /// <param name="bTinhTrang">1: da xac nhan; 2: chua xac nhan <param>
        /// <returns>dtKQ: sanh sach benh nhan</returns>
        private DataTable getDSBenhNhan(int nLoaiBN, int bTinhTrang)
        {
            DataTable dtKQ = new DataTable();
            GetThongTinSearchDTO tt = new GetThongTinSearchDTO();
            tt.STuNgay = DateTime.Parse(datTuNgay.EditValue.ToString()).ToString("yyyy-MM-dd");
            tt.SDenNgay = DateTime.Parse(datDenNgay.EditValue.ToString()).ToString("yyyy-MM-dd");
            tt.SDichVu = "";//hensu.DVcode;
            //tt.SDonViTH = UserDTO.MaDonVi;//don vi cua user dang nhap vao he thong
            tt.BTinhTrang = bTinhTrang;
            int tinhTrang = int.Parse(radTinhTrang.EditValue.ToString());
            if (tinhTrang == 2 )//da xat nhan
            {
                if (nLoaiBN == hensu.KSK)
                {
                    dtKQ = GetThongTinSearchBUS.GetDSDaXacNhanKSK(tt.STuNgay, tt.SDenNgay
                                     , nLoaiBN, 0);
                }
                else
                {
                    dtKQ = GetThongTinSearchBUS.GetDSDaXacNhan(tt.STuNgay, tt.SDenNgay
                                        , nLoaiBN, 0);
                }
            }          
            else//da co kq
            {
                if (nLoaiBN == hensu.KSK)
                {
                    dtKQ = GetThongTinSearchBUS.GetDSDaXacNhanKSK(tt.STuNgay, tt.SDenNgay
                                     , nLoaiBN, 1);
                }
                else
                {
                    dtKQ = GetThongTinSearchBUS.GetDSDaXacNhan(tt.STuNgay, tt.SDenNgay
                                                            , nLoaiBN, 1);
                }
                
            }
            return dtKQ;
        }

        public DateTime addNgay()
        {
            DateTime datetime1 = DateTime.Today;//Old dateTime
            int dayDifference = (int)datetime1.DayOfWeek - (int)DayOfWeek.Saturday;
            if (dayDifference == 0) //datetime1 day is Saturday
            {
                //neu la thu 7 thi tu dong chuyen sang thu 2               
                datetime1 = datetime1.AddDays(2);//now its monday
            }
            else
            {
                //nho kha thu 7 thi tu dong add them 1 ngay
                datetime1 = datetime1.AddDays(1);
            }         
            return datetime1;
        }

        /// <summary>
        /// set data khi sat nha dich vu
        /// </summary>
        /// <param name="lan">0: khong quan tam; 1: kq cat lanh; 2: kq gpb</param>
        /// <returns>tt dv gpb</returns>
        public TTXacNhanDTO setDataXacNhan(int lan)
        {            
            DataRow dr;
            dr = griddsBenhNhan.GetDataRow(griddsBenhNhan.FocusedRowHandle);
            TTXacNhanDTO xn = new TTXacNhanDTO();
            if (dr != null)
            {
                xn.SoHS = dr["sohs"].ToString();
                xn.SoBN = dr["sobn"].ToString();
                xn.SoNV = dr["sonhapvien"].ToString();
                xn.LoaiBN = int.Parse(graLoaiBenhNhan.EditValue.ToString());
                xn.HoTen = dr["hoten"].ToString();
                xn.NamSinh = int.Parse(dr["namsinh"].ToString());
                xn.Tuoi = int.Parse(dr["tuoi"].ToString());
                xn.Gioi = Boolean.Parse(dr["gioi"].ToString());
                xn.Nghe = dr["Nghe"].ToString();
                xn.NgayLayMau = DateTime.Parse(dr["ngaylaymau"].ToString());
                if (dr["NgayNhan"].ToString() != "")
                    xn.NgayNhan = DateTime.Parse(dr["NgayNhan"].ToString());
                else
                    xn.NgayNhan = DateTime.Now;
               
                xn.ChuanDoan = txtChuanDoan.Text;
                xn.PPMo = int.Parse(dr["ppmoid"].ToString());
                xn.IDDViChiDinh = lblDVChiDinhID.Text;
                xn.TenDViChiDinh = txtDVChiDinh.Text;
                xn.PTVien = int.Parse(dr["ptvid"].ToString());
                xn.IDBacSiCD = int.Parse(dr["idbscd"].ToString());
                if (txtsoxanh.Text != "")
                    xn.SoXanh = txtsoxanh.Text;
                else
                    xn.SoXanh = "0";
                if (dr["dvucode"].ToString() == "GE56")
                    lan = 2;
                else
                    lan = 1;
                if (lan == 1)
                {
                    xn.SoTieuBan = dr["bKetQua1"].ToString();
                }
                else if (lan == 2)
                {
                    xn.SoTieuBan = dr["bKetQua2"].ToString();
                }
                else
                {
                    xn.SoTieuBan = txtSoTieuBan.Text;
                }
                xn.IDDViGuiMau = comDVLayMau.EditValue.ToString();               
                xn.CDate = DateTime.Parse(DateTime.Today.ToString("yyyy-MM-dd"));
              
                if (dr["sotien"].ToString()!="")
                    xn.SoTien = int.Parse(dr["sotien"].ToString());
                else
                    xn.SoTien = 0;
                DataTable dt = KQBUS.GetKetQua(txtSoBN.Text, txtSoHS.Text, txtSoTieuBan.Text);
                if (dt.Rows.Count>0)
                {
                    if (dt.Rows[0]["KQDaiThe"].ToString() != "")
                        xn.KQ1 = txtSoTieuBan.Text;
                    else
                        xn.KQ1 = "0";
                }
                else
                {
                    xn.KQ1 = "0";
                    xn.KQ2 = "0";
                }
                xn.SoTieuBan = txtSoTieuBan.Text;
                xn.DVuCode = dr["dvucode"].ToString();// hensu.DVcode;
                xn.TenDVu = dr["tendvu"].ToString();

                xn.IDDviTHien = UserDTO.MaDonVi;
                xn.DienThoai = txtDienThoai.Text;
            }
            return xn;
        }

        public string Right(string value, int length)
        {
            return value.Substring(value.Length - length);
        }

        public void TaoSo()
        {           
            int nam = int.Parse(Right(DateTime.Today.Year.ToString(), 2));
            int thang = DateTime.Today.Month;
            string sox = "";
            DataTable dtMax = TTXacNhanBUS.GetMax(hensu.SoXanh, nam, thang);
            if (dtMax != null)
            {
                if (dtMax.Rows.Count > 0)
                {
                    maxSoXanh = int.Parse(dtMax.Rows[0]["SoMax"].ToString()) + 1;
                    sox = dtMax.Rows[0]["Thang"].ToString() + "." + maxSoXanh.ToString("0000");
                }
                else
                {
                    maxSoXanh = 1;
                    sox = thang + "." + maxSoXanh.ToString("0000");
                }
            }
            txtsoxanh.Text = sox;
        }

        /// <summary>
        /// frmMain_Load
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void frmMain_Load(object sender, EventArgs e)
        {           
            //set ngay thang nam
            datTuNgay.DateTime = DateTime.Now.Date;
            datDenNgay.DateTime = DateTime.Now.Date;
           
            comptv.Properties.DataSource = GetThongTinSearchBUS.SearchDSBacSiCD();
            comPPMo.Properties.DataSource = GetThongTinSearchBUS.SearchPPMo();
            comDVLayMau.Properties.DataSource = GetThongTinSearchBUS.SearchDonViGuiMau();
            comDDCoDinh.Properties.DataSource = GetThongTinSearchBUS.GetMDDungDichCD();
            radTinhTrang.SelectedIndex = 0;
            graLoaiBenhNhan.SelectedIndex = 0;
            
            if (int.Parse(radTinhTrang.EditValue.ToString()) == 1)
                btnKetQua.Enabled = false;
            else
                btnKetQua.Enabled = true;

            radTinhTrang.EditValue = select;
            radTinhTrang.SelectedIndex = 0;
            //
            CnPKham();
            firtLoad = false;
        }

        /// <summary>
        /// nhap ket qua cat lanh
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnKetQua_Click(object sender, EventArgs e)
        {
            if (txtSoHS.Text == "")
            {
                return;
            }
            TTXacNhanDTO xn = new TTXacNhanDTO();
            xn = setDataXacNhan(1);
            frmKetQuaCL frmKQ = new frmKetQuaCL(xn);
            frmKQ.thoatEven += new frmKetQuaCL.MyDelege2(frm_thoatEven);

            frmKQ.Show();
        }
        
        void frm_thoatEven(object sender, object data)
        {
            dataRes = (int[])data;
            if ((int)dataRes[0] == 1)
            {
                lblKQ1.Text = "true";
            }
            else if ((int)dataRes[0] == 2)
            {
                lblKQ2.Text = "true";
            }
            else
            {
                lblKQ1.Text = "false";
                lblKQ2.Text = "false";
            }
            if ((int)dataRes[1] == 1)
            {
                lblReload.Text = "true";
                ReLoadForm(sender);
            }
        }
        
        private void btnThoat_Click(object sender, EventArgs e)
        {
            Uit.it_Conn.disConnect();
            this.Close();
        }

        private void btnTim_Click(object sender, EventArgs e)
        {
            DataTable dtKQ = new DataTable();

            int loaiBenh = (int)graLoaiBenhNhan.EditValue;
            int tinhTrang = int.Parse(radTinhTrang.EditValue.ToString());
            //get danh sach benh nhan          
            dtKQ = getDSBenhNhan(loaiBenh, tinhTrang);
            //xu ly thong tin kq
            string dvCode="";
            if (dtKQ == null)
                return;
            int NhomPL = 0;
            for (int i = 0; i < dtKQ.Rows.Count; i++)
            {
                NhomPL = int.Parse(dtKQ.Rows[i]["IDLoai"].ToString());
                switch (NhomPL)
                {
                    case 1://CL
                        if (dtKQ.Rows[i]["bKetQua1"].ToString() != "0")
                            dtKQ.Rows[i]["KQ"] += hensu.sCatLanh;
                        if (dtKQ.Rows[i]["bKetQua2"].ToString() != "0")
                            dtKQ.Rows[i]["KQ"] += "+" + hensu.sGPB;//da co kq2
                        break;
                    case 2://GPB
                        if (dtKQ.Rows[i]["bKetQua1"].ToString() != "0")
                            dtKQ.Rows[i]["KQ"] += hensu. sGPB;
                        break;
                    case 3://FNA
                        if (dtKQ.Rows[i]["bKetQua1"].ToString() != "0")//da co kq
                        {
                            dtKQ.Rows[i]["KQ"] += hensu.sFNA;
                        }
                        break;
                    case 4://PAP
                        if (dtKQ.Rows[i]["bKetQua1"].ToString() != "0")//da co kq
                        {
                            dtKQ.Rows[i]["KQ"] += hensu.sPAP;
                        }
                        break;
                }
                //dvCode = dtKQ.Rows[i]["DVuCode"].ToString();
                //if (dvCode == "TN06" || dvCode == "TN12")
                //{
                //    if (dtKQ.Rows[i]["bKetQua1"].ToString() != "0")//da co kq
                //    {
                //        dtKQ.Rows[i]["KQ"] += hensu.sPAP;
                //    }
                //}
                //else if (dvCode == "GA04" || dvCode == "GA87" || dvCode == "GA08")
                //{
                //    if (dtKQ.Rows[i]["bKetQua1"].ToString() != "0")//da co kq
                //    {
                //        dtKQ.Rows[i]["KQ"] += hensu.sFNA;
                //    }
                //}
                //else if (dvCode == "GE56" )//cat lanh
                //{
                //    if (dtKQ.Rows[i]["bKetQua1"].ToString() != "0")
                //        dtKQ.Rows[i]["KQ"] += hensu.sCatLanh;
                //    if (dtKQ.Rows[i]["bKetQua2"].ToString() != "0")
                //        dtKQ.Rows[i]["KQ"] += "+"+hensu.sGPB;//da co kq2
                //}
                //else//gpb
                //{
                //    if (dtKQ.Rows[i]["bKetQua1"].ToString() != "0")
                //        dtKQ.Rows[i]["KQ"] += hensu.sGPB;
                //}
            }
            //set data len grid
            gridMain.DataSource = dtKQ;
            //
            initControl(this);
            btnBoXacNhan.Enabled = false;
        }

        bool checkXacNhan()
        {
            bool rs = true;
            if (comDVLayMau.EditValue == "")
            {
                dxErrorProvider1.SetError(comDVLayMau, "Xin hãy chọn đơn vị gửi mẩu");
                rs = false;
            }
            else
            {
                dxErrorProvider1.ClearErrors();
                rs = true;
            }
            if (txtsoxanh.Text == "0")
            {
                dxErrorProvider1.SetError(txtsoxanh, "Xin hãy nhập số xanh");
                rs = false;
            }
            else
            {
                dxErrorProvider1.ClearErrors();
                rs = true;
            }
            return rs;
        }
        
        private void btnXacNhan_Click(object sender, EventArgs e)
        {
            //this.btnXacNhan.Visible = false;
            try
            {
                 DataRow dr;
                dr = griddsBenhNhan.GetDataRow(griddsBenhNhan.FocusedRowHandle);
                if (dr == null)
                {
                    return;
                }
                if (checkXacNhan() == false)
                    return;
                TTXacNhanDTO xn = new TTXacNhanDTO();
                xn = setDataXacNhan(0);
                string MaDonVi = UserDTO.MaDonVi;
                if (TTXacNhanBUS.InsertDaXacNhan(xn))
                {
                    //update process
                    int nLoaiBN = int.Parse(graLoaiBenhNhan.EditValue.ToString());
                    TTXacNhanBUS.UpdateProcess(xn.SoBN, xn.SoHS, xn.SoNV
                                                , xn.DVuCode, true, nLoaiBN, conpk, MaDonVi);
                    //update so max lai    
                    int nam = int.Parse(Right(DateTime.Today.Year.ToString(), 2));
                    int thang = DateTime.Today.Month;
                    int max =  int.Parse(Right(txtsoxanh.Text,4));
                    TTXacNhanBUS.UpdateMax(hensu.SoXanh, nam, thang,max);
                    //set so max lai len form
                    
                }
                btnTim_Click(sender, e);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString(), "Thông Báo");
            }
        }
        
        /// <summary>
        /// bo xat nhan dich vu
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnBoXacNhan_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtSoHS.Text == "")
                {
                    return;
                }
                TTXacNhanDTO xn = new TTXacNhanDTO();
                xn = setDataXacNhan(0);

                if (TTXacNhanBUS.DeleteDaXacNhan(xn.SoHS, xn.SoBN))
                {
                    //update process
                    int nLoaiBN = int.Parse(graLoaiBenhNhan.EditValue.ToString());
                    TTXacNhanBUS.UpdateProcess(xn.SoBN, xn.SoHS, xn.SoNV
                                            , xn.DVuCode, false, nLoaiBN, conpk, UserDTO.MaDonVi);
                }
                btnTim_Click(sender, e);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Thông Báo", ex.Message.ToString());
            }
        }

        private void radTinhTrang_SelectedIndexChanged(object sender, EventArgs e)
        { 
            int tt = int.Parse(radTinhTrang.EditValue.ToString());
            switch (tt )
            {
            	case 1:
                    btnKetQua.Enabled = false; 
                    btnBoXacNhan.Enabled = false;
                    comDVLayMau.Enabled = true;
                    txtsoxanh.Enabled = true;
            		break;
                case 2:
                    btnKetQua.Enabled = true;
                    btnBoXacNhan.Enabled = true;                  
                    comDVLayMau.Enabled = false;
                    txtsoxanh.Enabled = false;
            		break;
                case 3:
                    btnKetQua.Enabled = true; 
                    btnBoXacNhan.Enabled = false; 
                    comDVLayMau.Enabled = false;
                    txtsoxanh.Enabled = false;
            		break;
            }
             
            if (firtLoad == false)
                btnTim_Click(sender, e);
        }

        private void gridMain_Click(object sender, EventArgs e)
        {
            try
            {
                DataRow dr;
                dr = griddsBenhNhan.GetDataRow(griddsBenhNhan.FocusedRowHandle);
                if (dr != null)
                {
                    //set value to information panel
                    txtHoTen.Text       = dr["hoten"].ToString();
                    txtTuoi.Text        = dr["namsinh"].ToString() 
                        + "(" + dr["tuoi"].ToString() + " Tuổi)";
                    txtGioi.Text        = dr["gioitinh"].ToString();
                    lblGioi.Text        = dr["gioi"].ToString();
                    txtNamSinh.Text     = dr["namsinh"].ToString();
                    txtSoHS.Text        = dr["sohs"].ToString();
                    txtSoBN.Text        = dr["sobn"].ToString();
                    txtSoNVien.Text     = dr["sonhapvien"].ToString();
                    txtDVChiDinh.Text   = dr["tendonvi"].ToString();
                    lblDVChiDinhID.Text = dr["madonvi"].ToString();
                    txtNghe.Text        = dr["Nghe"].ToString();
                    txtdiachi.Text      = dr["diachi"].ToString();
                    txtChuanDoan.Text   = Uit.it_Font.VNIToUnicode(dr["chandoan"].ToString());
                    comptv.EditValue    = dr["ptvid"].ToString();
                    comPPMo.EditValue   = dr["ppmoid"].ToString();
                    datNgayLayMau.EditValue 
                        = DateTime.Parse(dr["ngaylaymau"].ToString()).ToString("yyyy-MM-dd HH:mm");
                    
                    lblngaygui.Text     = dr["ngaynhan"].ToString();
                    lblngaylay.Text     = dr["ngaylaymau"].ToString();
                    txtDienThoai.Text   = dr["DienThoai"].ToString();
                    txtsoxanh.Text      =  dr["SoXanh"].ToString();
                    txtSoTieuBan.Text   = dr["SoTieuBan"].ToString();
                    comDVLayMau.EditValue = dr["IDDViGuiMau"].ToString();
                                 
                    if (int.Parse(radTinhTrang.EditValue.ToString()) == 2)
                    {
                        btnBoXacNhan.Enabled = true;
                    }
                  
                    if (int.Parse(radTinhTrang.EditValue.ToString()) == 3)
                    {
                        lblKQ1.Text = dr["bKetQua1"].ToString();
                        lblKQ2.Text = dr["bKetQua2"].ToString();                       
                    }
                    txtLanMo.Text = dr["LanMo"].ToString();
                    comDVLayMau.EditValue = dr["IDDViGuiMau"].ToString();
                    txtDienThoai.Text = dr["DienThoai"].ToString();
                    txtSlgMau.Text = dr["SoluongBP"].ToString();
                    txtChatBP.Text = dr["chatbp"].ToString();
                    if (dr["NgGioCoDinh"].ToString() != "")
                    {
                        txtNgayGioCoDinh.Text
                            = DateTime.Parse(dr["NgGioCoDinh"].ToString()).ToString("yyyy-MM-dd HH:mm"); //dr["NgGioCoDinh"].ToString(); 
                    }
                    else
                    {
                        txtNgayGioCoDinh.Text = "";
                    }
                    comDDCoDinh.EditValue = dr["IDdungdichcd"].ToString();
                    //neu da co ket qua khong cho bo xac nhan
                    if (dr["KQ"].ToString() != "")
                    {
                        btnBoXacNhan.Enabled = false;
                    }
                    else
                    {
                        btnBoXacNhan.Enabled = true;
                    }
                }
                else
                {
                    btnBoXacNhan.Enabled = false;
                }                
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString(), "Thông Báo");
            }
        }

        private void gridMain_KeyUp(object sender, KeyEventArgs e)
        {
            gridMain_Click( sender,  e);
        }

        private void ReLoadForm(object sender)
        {
            EventArgs e = new EventArgs ();
            if (lblReload.Text == "true")
            {
                btnTim_Click(sender, e);
            }
        }
        private void lblReload_TextChanged(object sender, EventArgs e)
        {
            if (lblReload.Text == "true")
            {
                btnTim_Click(sender, e);
            }
        }

        private void lblReload_Validated(object sender, EventArgs e)
        {
            if (lblReload.Text == "true")
            {
                btnTim_Click(sender, e);
            }
        }
        public static void DanhSoThuTu(RowIndicatorCustomDrawEventArgs e)
        {
            if (e.Info.IsRowIndicator)
            {
                if (e.RowHandle < 0)
                    e.Info.DisplayText = "";
                else
                    e.Info.DisplayText = (e.RowHandle + 1).ToString();
            }
            else
            {
                e.Info.DisplayText = "STT";
            }
            e.Info.Appearance.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Far;
        }

        private void gridDSBenhNhan_CustomDrawRowIndicator(object sender, RowIndicatorCustomDrawEventArgs e)
        {
            
        }

        private void griddsBenhNhan_CustomDrawRowIndicator(object sender, RowIndicatorCustomDrawEventArgs e)
        {
            DanhSoThuTu(e);
        }

        private void barRpDaXacNhan_ItemClick(object sender, ItemClickEventArgs e)
        {
            frmThongKe frmTK = new frmThongKe();
            frmTK.ShowDialog();
        }

        private void btnNhapKQPAP_Click(object sender, EventArgs e)
        {
            if (txtSoHS.Text == "")
            {
                return;
            }
            TTXacNhanDTO xn = new TTXacNhanDTO();
            xn = setDataXacNhan(1);
            frmKQTeBaoPAP frmkq = new frmKQTeBaoPAP(xn);
            frmkq.thoatEven += new frmKQTeBaoPAP.MyDelege2(frm_thoatEven);
            frmkq.Show();
        }

        private void btnNhapKQGPB_Click(object sender, EventArgs e)
        {
            if (txtSoHS.Text == "")
            {
                return;
            }
            TTXacNhanDTO xn = new TTXacNhanDTO();
            xn = setDataXacNhan(2);
            frmKetQuaGPB frmKQ = new frmKetQuaGPB(xn);
            frmKQ.thoatEven += new frmKetQuaGPB.MyDelege2(frm_thoatEven);

            frmKQ.Show();
        }

        private void btnNhapKQFNA_Click(object sender, EventArgs e)
        {
            if (txtSoHS.Text == "")
            {
                return;
            }
            TTXacNhanDTO xn = new TTXacNhanDTO();
            xn = setDataXacNhan(2);
            frmKetQuaFNA frmKQ = new frmKetQuaFNA(xn);
            frmKQ.thoatEven += new frmKetQuaFNA.MyDelege2(frm_thoatEven);

            frmKQ.Show();
        }

        private void btnHoanTien_Click(object sender, EventArgs e)
        {
            TTXacNhanDTO xn = new TTXacNhanDTO();
            xn = setDataXacNhan(2);
            frmHoanTien frmHT = new frmHoanTien(xn);
            frmHT.Show();
        }

        private void btnCapNhatCBP_Click(object sender, EventArgs e)
        {

        }
    }
}